<template>
	<view class=" beijingse">
		<view class="u-demo-block">
			<u-swiper :list="list6" @change="e => currentNum = e.current" :autoplay="false" indicatorStyle="right: 20px"
				height="217" imgMode="aspectFit " indicator indicatorMode="line">
				<view slot="indicator" class="indicator-num">
					<text class="indicator-num__text">{{ currentNum + 1 }}/{{ list6.length }}</text>
				</view>
			</u-swiper>
		</view>
		<view class="neirong">
			<view class="mainpadding">
				<view class="ffffff radius mainpadding">
					<view class="flexbetween">
						<view class="">
							<view class="titletext">{{dianpxq.name}}</view>
							<view class="huisetext margin_top1">{{dianpxq.tel}}</view>
							<view class="huisetext" style="margin-top: 4rpx;">{{dianpxq.address}}</view>
						</view>
						<view class="flexright">
							<view class="dpicon margin_right2" @click="openmap()">
								<image src="../../static/image/system/ditu.png" mode=""></image>
							</view>
							<view class="dpicon" @click="phone(dianpxq.tel)">
								<image src="../../static/image/system/dianhua.png" mode=""></image>
							</view>
						</view>
					</view>
				</view>
				<view class="ffffff mainpadding radius flexleft margin_top" v-for="item in list.data" @click="tzspxq(item.id)">
					<view class="shilitu margin_right2" style="flex: 1.5;">
						<image :src="item.image_text" mode=""></image>
					</view>
					<view class="" style="flex: 6;">
						<view class="ershil xiankuan">{{item.title}}</view>
						<view class="qianshu margin_top5">￥{{item.price}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				lat: "",
				lon: "",
				currentNum: 0, //轮播图当前位置
				dianpxq: {
					tel: "",
					name: "",
					address: "",
				},
				dianpuid: "",//店铺id
				list6: [],
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onLoad(options) {
			this.getlocation()
			this.dianpuid = options.id;
			this.dianpuxq()
			this.init()
		},
		methods: {
			// 商品列表
			init(isPage, page) {
				let _this = this;
				httpRequest.request('/api/shop/goodsList1', 'POST', {
					page: page || 1,
					limit: _this.limit,
					shop_id: this.dianpuid
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							_this.list = resList
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			// 获取当前位置信息
			getlocation() {
				let _this = this
				uni.getLocation({
					type: 'wgs84',
					geocode: true, //设置该参数为true可直接获取经纬度及城市信息
					success: function(res) {
						_this.lat = res.latitude
						_this.lon = res.longitude
					},
					fail(err) {
						console.log(err, "定位错误信息")
					}
				});
			},
			// 打开地图
			openmap() {
				console.log(666)
				let _this = this
				uni.openLocation({
					latitude: Number(_this.dianpxq.latitude), //即将传到高德或腾讯地图的终点纬度  必须是数值，字符串无效
					longitude: Number(_this.dianpxq.longitude), //即将传到高德或腾讯地图的终点经度  必须是数值，字符串无效
					name: _this.dianpxq.address_detail, //即将传到高德或腾讯地图的店铺名称
					address: _this.dianpxq.address, //即将传到高德或腾讯地图的详细地址
				})
			},
			phone(p) {
				uni.makePhoneCall({
					phoneNumber: p.toString(),
					success(ress) {
						console.log("拨打电话成功", ress)
					},
					fail(err) {
						console.log("拨打电话失败", err)
					}

				})
			},
			// 店铺详情
			dianpuxq() {
				httpRequest.request('/api/shop/shopDetail', 'POST', {
					// 传参
					shop_id: this.dianpuid
				}, false, false, true).then(res => {
					if (res.code == 1) {
						this.dianpxq = res.data
						this.list6 = res.data.images_text
					}
				})
			},
			// 跳转商品详情
			tzspxq(id) {
				uni.navigateTo({
					url: '/pages/homepage/shangpxqxxzyd?id='+id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.qianshu {
		font-size: 24rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #FAB536;
	}

	.ershil {
		font-size: 24rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #333333;
	}

	.shilitu {
		width: 125rpx;
		height: 125rpx;
		border-radius: 11rpx;

		image {
			width: 100%;
			height: 100%;
			border-radius: 11rpx;
		}
	}

	.neirong {
		position: relative;
		top: -48rpx;
	}

	.dpicon {
		width: 51rpx;
		height: 51rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.huisetext {
		font-size: 22rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}

	.indicator {
		@include flex(row);
		justify-content: center;

		&__dot {
			height: 6px;
			width: 6px;
			border-radius: 100px;
			background-color: rgba(255, 255, 255, 0.35);
			margin: 0 5px;
			transition: background-color 0.3s;

			&--active {
				background-color: #ffffff;
			}
		}
	}

	.indicator-num {
		padding: 2px 0;
		background-color: rgba(0, 0, 0, 0.35);
		border-radius: 100px;
		width: 35px;
		@include flex;
		justify-content: center;

		&__text {
			color: #FFFFFF;
			font-size: 12px;
		}
	}
</style>
